package br.com.alinesoftware.app.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.annotations.ForeignKey;

import com.powerlogic.jcompany.domain.validation.PlcUnifiedValidation;
import java.util.List;
import javax.persistence.OneToMany;
import javax.persistence.CascadeType;

@MappedSuperclass
@PlcUnifiedValidation
public abstract class Fluxo implements Serializable {

	private static final long serialVersionUID = 5796359395142420312L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SE_FLUXO")
	@Column(nullable = false, length = 5)
	private Long id;

	@NotNull
	@Size(max = 255)
	@Column
	// private List<PassoFluxo> passosFluxo;
	private String descricaoFluxo;

	@ManyToOne(targetEntity = EstabelecimentoEntity.class, fetch = FetchType.LAZY)
	@ForeignKey(name = "FK_FLUXO_ESTABELEC")
	@NotNull
	@JoinColumn
	private Estabelecimento estabelecimento;
	
	@OneToMany (targetEntity = br.com.alinesoftware.app.entity.PassoFluxoEntity.class, fetch = FetchType.LAZY, cascade=CascadeType.ALL, mappedBy="fluxo")
	@ForeignKey(name="FK_PASSOFLUXO_FLUXO")
	private List<PassoFluxo> passoFluxo;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getDescricaoFluxo() {
		return descricaoFluxo;
	}

	public void setDescricaoFluxo(String descricaoFluxo) {
		this.descricaoFluxo = descricaoFluxo;
	}

	public Estabelecimento getEstabelecimento() {
		return estabelecimento;
	}

	public void setEstabelecimento(Estabelecimento estabelecimento) {
		this.estabelecimento = estabelecimento;
	}

	public List<PassoFluxo> getPassoFluxo() {
		return passoFluxo;
	}

	public void setPassoFluxo(List<PassoFluxo> passoFluxo) {
		this.passoFluxo=passoFluxo;
	}

}
